package com.example.demo2.dao;

import com.example.demo2.model.BookInfo;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;



//@Repository
@Component
public class BookDao {


//    填入一些临时捏造的数据用于测试
    public List<BookInfo> mockInfos() {

        //    创建一个图书馆
        List<BookInfo> bookInfos = new ArrayList<>();
        for (int i = 0; i < 20; i++) {
            Random r  =  new Random();
            BookInfo bookInfo  = new BookInfo();
            bookInfo.setBookName("神奇的魔法书第"+ i + "部珍藏版");
            bookInfo.setId(i);
            bookInfo.setNum(r.nextInt(500));
            bookInfo.setAuthor("大牛"+i +"大作家");
            bookInfo.setPrice(new BigDecimal(r.nextInt(70) + 20));
            bookInfo.setPublish("清华大学"+ i + "号分院出版社");
            bookInfo.setStatus(r.nextInt(200) % 2 == 0 ? 0 : 1);
            bookInfos.add(bookInfo);
        }

        return bookInfos;
    }
}
